import request from '@/common/request'

// 验证二维码是否可用
export function checkCode(code) {
  return request({
    url: '/quality/witness/validateQrCode',
    method: 'post',
	data:{
		qrCode: code,
		version: 1
	}
  })
}

// 获取原材料信息
export function getOptions(data) {
  return request({
    url: '/quality/material/queryMaterialMap',
    method: 'get',
    params:data
  })
}

// 根据分类id查询取样表单
export function getFormField(code) {
  return request({
    url: '/quality/sampling/info',
    method: 'post',
	data:{
		qrCode:code
	}
  })
}

// 保存取样数据
export function save(data) {
  return request({
    url: '/quality/witness/submit',
    method: 'post',
    data: data
  })
}

// 根据二维码code查询取样见证信息
export function getSampleInfo(code) {
  return request({
    url: '/quality/sampling_query/info',
	method: 'post',
    data:{
    	qrCode: code,
    }
  })
}

// 取样见证信息列表
export function sampleList(data) {
  return request({
    url: '/quality/sampling_query/list',
    method: 'post',
		data: data
  })
}

// 委托单打印授权
export function sampleAuth(id, type) {
  return request({
    url: '/quality/sampling/allowPrint/'+id+'/'+type,
    method: 'get'
  })
}
// 地图是否在范围内
export function getValueByCode() {
  return request({
    url: '/quality/baseConfig/getValueByCode?code=isCheckProjectMapRange',
    method: 'get',
    	// params: query
  })
}

// 委托单生成
export function sampleCreate(data, id) {
  return request({
    url: '/quality/sampling/createOrder/'+id,
    method: 'post',
		data: data,
		timeout: 180000
  })
}

// 查询当前项目下检测机构
export function checkCompanys(data) {
  return request({
    url: '/quality/project/checkCompanys',
    method: 'post',
		data: data
  })
}

// 查询样品动态字段
export function getSampleFormField(code) {
  return request({
    url: `/quality/sampling_query/formDataInfo`,
    method: 'post',
		data:{
		  qrCode: code
		}
  })
}
// 保存样品动态字段
export function saveSampleFormField(data) {
  return request({
    url: `/quality/sampling_query/updateFormData`,
    method: 'post',
		data: data
  })
}